#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define pb emplace_back
#define ll long long
using namespace std;

int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,m,B;

vector<vector<bool>> mp;

bool ok(int x,int y){return x&&y&&(x<=n)&&(y<=m)&&(mp[x-1][y]+mp[x][y-1]+mp[x+1][y]+mp[x][y+1]>=2);}
ll solve(){
	queue<pii> q;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(mp[i][j]) q.push({i,j});
	while(!q.empty()){
		auto p=q.front();q.pop();auto x=p.fi,y=p.se;
		for(int i=0;i<4;i++) if(!mp[x+dx[i]][y+dy[i]]&&ok(x+dx[i],y+dy[i])){
			mp[x+dx[i]][y+dy[i]]=1;q.push({x+dx[i],y+dy[i]});
		}
	}
	ll ans=0;for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) ans+=mp[i][j];
	return ans;
}
vector<pii> c;

int main(){
	/* *
	freopen("grid.in","w",stdout);
	n=m=B=50000;
	cout<<n<<' '<<m<<' '<<B<<endl;
	for(int i=1;i<=n;i++) cout<<i<<' '<<i<<endl;
	return 0;
	// */
	freopen("grid.in","r",stdin);
	freopen("grid.out","w",stdout);
	cin.tie(nullptr)->sync_with_stdio(false);
	int i,x,y;
	cin>>n>>m>>B;
	for(i=1;i<=B;i++) cin>>x>>y,c.pb(x,y);
	if(n*m>=1e8){
		map<int,int> col,row;
		for(auto p:c)
			col[p.fi-1]++,col[p.fi]++,col[p.fi+1]++,
			row[p.se-1]++,row[p.se]++,row[p.se+1]++;
		col.erase(0),col.erase(n+1);
		row.erase(0),row.erase(m+1);
		int tot;
		tot=0;for(auto& p:col) p.se=++tot;n=tot;
		tot=0;for(auto& p:row) p.se=++tot;m=tot;
		for(auto& p:c) p.fi=col[p.fi],p.se=row[p.se];
	}
	mp.resize(n+2);for(auto& x:mp) x.resize(m+2);
	for(auto p:c){
		mp[p.fi][p.se]=1;
	}
	cout<<solve()<<'\n';
	return 0;
	return 0;
}